<?php

/**
 * RaiseHiddenField UIControl class
 * A hidden text field UI control
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.Core.UI.Form
 * @since 1.2
 */
class RaiseHiddenField extends RaiseFormField {

    /**
     * Create new RaiseTextField
     */
    public function __construct() {
        $this->tag = new RaiseHtmlTag('input', '', array('type' => 'hidden'));
    }
    
    /**
     * Get or set the value of the hidden text field
     * @param string $v (optional) If passed in, the new value will be set.
     * @return string
     */
    public function value($v = false){
        if(func_num_args() == 1){
            $this->tag->attributes()->add('value', $v);
        }
        return $this->tag()->attributes()->get('value');
    }

    public function output() {
        if($this->clientId()){
            $this->tag->attributes()->add('id', $this->clientId());
            $this->tag->attributes()->add('name', $this->clientId());
        }
        if($this->cssClass()){
            $this->tag->attributes()->add('class', $this->cssClass());
        }
        return $this->tag->html();
    }

}

